home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / math.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-05  |  3.6 KB  |  133 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.  
  3.     Math.h
  4.     C Interface to the Macintosh Libraries
  5.  
  6.  
  7.     Copyright Apple Computer, Inc.    1985-1995
  8.     All rights reserved
  9.     
  10. ************************************************************/
  11.  
  12.  
  13. #ifndef __MATH_H__
  14. #define __MATH_H__
  15.  
  16. /*
  17.     Strictly conforming implementations must have the parameters to these routines
  18.     be double, not long double.  They still get evaluated to long double precision
  19.     on the 68K.  We expect that a lot of this confusion will eventually get settled
  20.     by NCEG and then we will do it the NCEG way.
  21. */
  22.  
  23. #if (__STDC__ == 1) || defined(powerc)
  24. #define _float_eval double
  25. #else /*__STDC__*/
  26. #define _float_eval long double
  27. #endif /*__STDC__*/
  28.  
  29. #define HUGE_VAL __inf()
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. /*
  36.  *    We put underscores on the formal parameter names to reduce name space pollution.
  37.  *    Plum-Hall tests require that we do this:  they have macros called exp, size etc.
  38.  */
  39.  
  40. /*
  41.  *    ANSI routines
  42.  */
  43.  
  44. _float_eval sin(_float_eval _x);
  45. _float_eval cos(_float_eval _x);
  46. _float_eval tan(_float_eval _x);
  47. _float_eval asin(_float_eval _x);
  48. _float_eval acos(_float_eval _x);
  49. _float_eval atan(_float_eval _x);
  50. _float_eval atan2(_float_eval _y,_float_eval _x);
  51. _float_eval sinh(_float_eval _x);
  52. _float_eval cosh(_float_eval _x);
  53. _float_eval tanh(_float_eval _x);
  54. _float_eval exp(_float_eval _x);
  55. _float_eval log(_float_eval _x);
  56. _float_eval log10(_float_eval _x); 
  57. _float_eval frexp(_float_eval _x,int *_exp);
  58. _float_eval ldexp(_float_eval _x,int _n);
  59.  
  60. _float_eval modf(_float_eval _x, _float_eval *_ip);
  61.  
  62. _float_eval pow(_float_eval _x,_float_eval _y);
  63. _float_eval sqrt(_float_eval _x);
  64. _float_eval floor(_float_eval _x); 
  65. _float_eval ceil(_float_eval _x);
  66. _float_eval fmod(_float_eval _x,_float_eval _y);
  67. _float_eval fabs(_float_eval _x);
  68.  
  69. _float_eval __inf(void);
  70.  
  71. /*
  72.  *  Apple extentions
  73.  */
  74.  
  75. /* CFront can't handle the pretty version of this conditional 
  76. #if defined (__useAppleExts__) || \
  77.     ((defined (applec) && ! defined (__STDC__)) || \
  78.      (defined (__PPCC__) && __STDC__ == 0))
  79. */
  80. #if defined (__useAppleExts__) || ((defined (applec) && ! defined (__STDC__)) || (defined (__PPCC__) && __STDC__ == 0))
  81.  
  82. #if defined (__CFM68K__) && !defined (UsingStaticLibs)
  83.     #pragma import on
  84. #endif
  85.  
  86. char *ecvt(extended value,int ndigit,int *decpt,int *sign);     /* Imported from StdCLib. */
  87. char *fcvt(extended value,int ndigit,int *decpt,int *sign);     /* Imported from StdCLib. */
  88.  
  89. #if defined (__CFM68K__) && !defined (UsingStaticLibs)
  90.     #pragma import off
  91. #endif
  92.  
  93. _float_eval hypot(_float_eval _x,_float_eval _y);
  94.  
  95.  
  96. #ifdef powerc
  97. /*
  98.  *    If you use modf() you must decide which version you mean: modf(),
  99.  *    modff() or modfl().  The usual promotions to long double don't
  100.  *    help here because we're using a pointer.
  101.  *
  102.  *    NOTE:    both modff() and modfl() are not ANSI defined functions;
  103.  *            if you use it, your code may not be portable.
  104.  */
  105.  
  106. float modff(float _x,float *_ip);
  107. long double modfl(long double _x, long double *_ip);
  108.  
  109. #else
  110. /*
  111.  * For the 68K, these are defined as macros which evaluate to modf(),
  112.  * since for the 68K world there is no difference between modf(), modff(),
  113.  * and modfl().  (Functional implementations are also provided if you are
  114.  * linking with MathLib.o.  If you link with CSANELib.o and Math.o,
  115.  * attempting to use the function instead of the macro will cause link
  116.  * errors as these are not available as functions in the older SANE engine.)
  117.  */
  118.  
  119. float modff(float _x,float *_ip);
  120. #define modff(_x,_ip) modf(_x,_ip)
  121. long double modfl(long double _x, long double *_ip);
  122. #define modfl(_x,_ip) modf(_x,_ip)
  123.  
  124. #endif
  125.  
  126. #endif
  127.  
  128. #ifdef __cplusplus
  129. }
  130. #endif
  131.  
  132. #endif
  133.